package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.DevAmTicketItemDao;
import com.sugon.entity.DevAmTicketItemEntity;
import com.sugon.service.DevAmTicketItemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 设备自主维护工单项Service实现类
 *
 * @author YuXD
 * @date 2023-01-23
 */
@Service("devAmTicketItemService")
public class DevAmTicketItemServiceImpl implements DevAmTicketItemService {

    @Resource
    private DevAmTicketItemDao devAmTicketItemDao;

    /**
     * queryObject
     *
     * @param id 主键
     * @return
     */
    @Override
    public DevAmTicketItemEntity queryObject(String id) {
        return devAmTicketItemDao.queryObject(id);
    }

    @Override
    public List<DevAmTicketItemEntity> queryByTicketId(String ticketId) {
        Map<String, Object> queryParam = MapUtil.newHashMap();
        queryParam.put("devMainTicketId", ticketId);
        return devAmTicketItemDao.queryList(queryParam);
    }

    /**
     * queryList
     *
     * @param map 参数
     * @return
     */
    @Override
    public List<DevAmTicketItemEntity> queryList(Map<String, Object> map) {
        return devAmTicketItemDao.queryList(map);
    }

    /**
     * queryTotal
     *
     * @param map 参数
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return devAmTicketItemDao.queryTotal(map);
    }

    /**
     * save
     *
     * @param devAmTicketItem 实体
     * @return
     */
    @Override
    public int save(DevAmTicketItemEntity devAmTicketItem) {
        devAmTicketItem.setId(RandomUtil.randomString(32));
        devAmTicketItem.setGmtCreate(DateUtil.date());
        // 默认为无异常清醒
        devAmTicketItem.setCheckResult(0);
        // 默认为未处理
        devAmTicketItem.setStatus(0);
        return devAmTicketItemDao.save(devAmTicketItem);
    }

    /**
     * update
     *
     * @param devAmTicketItem 实体
     * @return
     */
    @Override
    public int update(DevAmTicketItemEntity devAmTicketItem) {
        return devAmTicketItemDao.update(devAmTicketItem);
    }

    /**
     * delete
     *
     * @param id
     * @return
     */
    @Override
    public int delete(String id) {
        return devAmTicketItemDao.delete(id);
    }

    /**
     * deleteBatch
     *
     * @param ids
     * @return
     */
    @Override
    public int deleteBatch(String[] ids) {
        return devAmTicketItemDao.deleteBatch(ids);
    }

}
